package com.yehongyu.mytools.network;

import java.net.InetAddress;
import java.net.UnknownHostException;

public class NetUtil {

	public static void main(String[] args){
		// host info
        String hostName;
        String hostAddress;

        try {
            InetAddress localhost = InetAddress.getLocalHost();

            hostName = localhost.getHostName();
            hostAddress = localhost.getHostAddress();
        } catch (UnknownHostException e) {
            hostName = "localhost";
            hostAddress = "127.0.0.1";
        }
        System.out.println(hostName);
        System.out.println(hostAddress);
	}
}
